package com.cskaoyan.controller.lzp_controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.Keyword;
import com.cskaoyan.bean.lzp.KeywordCreatBO;
import com.cskaoyan.bean.lzp.KeywordData;
import com.cskaoyan.bean.params.BaseParam;
import com.cskaoyan.service.KeywordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * \* Description:
 * \* @author: Lizhanpeng
 * \* Date: 2022/5/6
 * \
 */
@RestController
@RequestMapping("admin/keyword")
public class KeywordController {
    @Autowired
    KeywordService keywordService;

    @GetMapping("list")
    public BaseRespVo keywordList(BaseParam baseParam,String keyword,String url){
        KeywordData keywordData = keywordService.query(baseParam,keyword,url);
        return BaseRespVo.listOk(keywordData);
    }

    @PostMapping("create")
    public BaseRespVo keywordCreate(@RequestBody KeywordCreatBO keywordCreatBO){
        Keyword keyword = keywordService.create(keywordCreatBO);
        return BaseRespVo.listOk(keyword);
    }

    @PostMapping("delete")
    public BaseRespVo keywordDelete(@RequestBody Keyword keyword){
        keywordService.delete(keyword);
        return  BaseRespVo.listOk(null);
    }

    @PostMapping("update")
    public BaseRespVo keywordUpdate(@RequestBody Keyword keyword){
       Keyword keyword1=  keywordService.update(keyword);

       return BaseRespVo.listOk(keyword1);
    }


}